uncompressing .zip file in linux [closed]

Posted by Suren on Stack Overflow See other posts from Stack Overflow or by Suren
Published on 2010-02-23T21:07:19Z Indexed on 2010/04/17 1:43 UTC
Read the original article Hit count: 465

Filed under:
|

hi,

I have a .zip file (It contains multiple files, ex: file1.txt file2.txt file3.txt.. n so on) in a directory.

And my query is:

How to extract the files from .zip archive to the very same directory and how to create the list of all the files extracted from .zip archive.**

The extracted file name should be printed like this in the file named: file_list:

file1.txt
file2.txt
file3.txt
filen.txt

I have tried the following command assuming that my .zip file name is "data.zip".

unzip -qoj data.zip | unzip -ql data.zip  > file_list 

I have used unzip -qoj data.zip to extract all the files in the same directory(quietly,overwrite,junk_path). When I try to insert -l with the first unzip command then the command doesn't extract the file in the current and only files are listed thats why I have to used unzip again after the first pipe(If I am making a mistake here let me know please).

I get the following output

 Length     Date   Time    Name
 --------    ----   ----    ----
        0  12-21-09 14:25   data/
     6148  12-21-09 14:25   data/.DS_Store
        0  12-21-09 14:25   __MACOSX/
        0  12-21-09 14:25   __MACOSX/data/
       82  12-21-09 14:25   __MACOSX/data/._.DS_Store
       82  12-11-09 13:59   data/file1.txt
      120  12-11-09 13:59   data/file2.txt
      166  12-11-09 13:59   data/file3.txt
 --------                   -------
     6598                   8 files

How do I extract only file1.txt file2.txt file3.txt from this stdout?

Is it possible to do this with linux command or I have to write a perl script for this?

Thank you.

© Stack Overflow or respective owner

Related posts about linux

Related posts about unzip